<?php
/**
 */
namespace haibao\cms\business\control;
use haibao\cms\model\filter\Video as VideoFilter;
use haibao\cms\model\filter\VideoCategory as VideoCategoryFilter;
use haibao\cms\model\filter\ImageLibrary as ImageLibraryFilter;
use haibao\cms\model\filter\VideoProperty as VideoPropertyFilter;
use haibao\cms\model\filter\FeaturePublish as FeaturePublishFilter;
use haibao\cms\model\filter\VideoRelTag as VideoRelTagFilter;
use haibao\frame\data\query\Pager;
use haibao\frame\data\query\Condition;
use haibao\cms\data\Video;
use haibao\cms\model\filter\VideoFile as VideoFileFilter;
use haibao\cms\model\data\VideoFile;

class VideoController extends \haibao\cms\business\control\Base{

	const ONE_MONTH = 1;
	public static $videoCategory = array(
			2=>array('报尚名来'=>26,'潮我看齐'=>27,'明星撞衫咚咚锵'=>28,'摩范先生'=>226),//明星风尚=>报尚名来,潮我看齐,明星撞衫咚咚锵,摩范先生
			230=>array('恋物志'=>227,'不将就'=>228),//态度人生=>恋物志,不将就
			231=>array('海报说'=>229,'尚道'=>232,'大咖不怕问'=>233,'海报独家专访'=>236),//话题专访=>海报说,尚道,大咖不怕问,海报独家专访
			234=>array('报告老师'=>235,'星妆上报'=>237),//美容彩妆=>报告老师,星妆上报
	);
	
	public static $videoCategoryName = array(
			2=> '明星风尚',
			230=>'态度人生',
			231=>'话题专访',
			234=>'美容彩妆',
	);
	
	public static $videoCategoryNameInMobile = array(
			0=>'全部视频',
			2=> '明星风尚',
			230=>'态度人生',
			231=>'话题专访',
			234=>'美容彩妆',
	);
	
	/**
	 * 根据视频分类获取视频数据
	 * @param  $categoryId
	 */
	public static function getNewVideoListByCategoryId($categoryId,$page,$isPage=true,$limit=12,$isJoinCategory=true,$isFeature=true,$notInVideoId=array(),$isH5Exist=0){
		
		$videoFilter = new VideoFilter();
		$videoCategoryFilter = new VideoCategoryFilter();
		$imageLibraryFilter = new ImageLibraryFilter();
		$videoFileFilter = new VideoFileFilter();
		$videoFilter->select(array(
				VideoFilter::CONDITION_FIELD_NAME_ID,
				VideoFilter::CONDITION_FIELD_NAME_CATEGORYID,
				VideoFilter::CONDITION_FIELD_NAME_PROPICURL,
				VideoFilter::CONDITION_FIELD_NAME_PUBLISHDATE,
				VideoFilter::CONDITION_FIELD_NAME_VOLNUM,
				VideoFilter::CONDITION_FIELD_NAME_TITLE,
				VideoFilter::CONDITION_FIELD_NAME_FEATUREID
		));
		$videoCategoryFilter->select(array(
				VideoCategoryFilter::CONDITION_FIELD_NAME_CATEGORYNAME
		));
		$imageLibraryFilter->select(array(
				ImageLibraryFilter::CONDITION_FIELD_NAME_FILENAME
		));
		$videoFileFilter->select(array(
				$videoFileFilter::CONDITION_FIELD_NAME_ID,
				$videoFileFilter::CONDITION_FIELD_NAME_STATUS
		));
		
		if($isPage){
			$videoFilter->setPager(new Pager($limit,$page));
		}else{
			if($limit){
				$videoFilter->limit($limit);
			}
		}
		
		
		if(is_array($categoryId)){
			$videoFilter->where(VideoFilter::CONDITION_FIELD_NAME_CATEGORYID,Condition::CONDITION_IN,$categoryId);
		}else{
			
			if(in_array($categoryId, array(2,230,231,234))){
				$videoParentFilter = new VideoCategoryFilter();
				$videoParentFilter->select(array(
						$videoParentFilter::CONDITION_FIELD_NAME_ID,
						$videoParentFilter::CONDITION_FIELD_NAME_STATUS,
				));
				$videoParentFilter->where($videoParentFilter::CONDITION_FIELD_NAME_PARENTID, Condition::CONDITION_EQUAL, (int)$categoryId);
				$videoParentFilter->where($videoParentFilter::CONDITION_FIELD_NAME_STATUS, Condition::CONDITION_EQUAL, \haibao\cms\model\data\VideoCategory::STATUS_ENABLE);
				
				$data = new \haibao\cms\data\Video();
				$childrenList = $data->getAll($videoParentFilter);
				$childrenIds =array();
				foreach ($childrenList as $key=>$val){
					array_push($childrenIds, $val->Id);
				}
				$videoFilter->where(VideoFilter::CONDITION_FIELD_NAME_CATEGORYID,Condition::CONDITION_IN,$childrenIds);
				
			}else {
				$videoFilter->where(VideoFilter::CONDITION_FIELD_NAME_CATEGORYID,Condition::CONDITION_EQUAL,(int)$categoryId);
			}
		}
		$videoFilter->where(VideoFilter::CONDITION_FIELD_NAME_STATUS,Condition::CONDITION_EQUAL,\haibao\cms\model\data\Video::STATUS_ENABLE);
		$videoFilter->where(VideoFilter::CONDITION_FIELD_NAME_PUBLISHED,Condition::CONDITION_EQUAL,\haibao\cms\model\data\Video::PUBLISHED_OK);
		$videoFilter->order(VideoFilter::CONDITION_FIELD_NAME_PUBLISHDATE,false);
		if($isJoinCategory){
			$videoFilter->innerJoin($videoCategoryFilter,null,VideoFilter::CONDITION_FIELD_NAME_CATEGORYID,VideoCategoryFilter::CONDITION_FIELD_NAME_ID,VideoFilter::CONDITION_FIELD_NAME_CATEGORY,false);
		}
		
		if($notInVideoId){
			$videoFilter->where(VideoFilter::CONDITION_FIELD_NAME_ID,Condition::CONDITION_NOTIN,$notInVideoId);
		}
		
		if($isH5Exist){
			$videoFilter->where(VideoFilter::CONDITION_FIELD_NAME_URLH5, Condition::CONDITION_NOTEQUAL,'');
		}
		
		$videoFilter->leftJoin($imageLibraryFilter,null,VideoFilter::CONDITION_FIELD_NAME_PICID,ImageLibraryFilter::CONDITION_FIELD_NAME_ID,VideoFilter::CONDITION_FIELD_NAME_PIC_URL,false);
				
		$videoFilter->leftJoin($videoFileFilter,null,VideoFilter::CONDITION_FIELD_NAME_ID,$videoFileFilter::CONDITION_FIELD_NAME_VIDEOID,VideoFilter::CONDITION_FIELD_NAME_VIDEOFILE,false);
		
		$data = new \haibao\cms\data\Video();
		$resultList = $data->getAll($videoFilter);
		$videoList = array();
		

		if($isFeature){
			$featureUrls = $featureIds = array();
			foreach ($resultList as $list){
				if($list->FeatureId) array_push($featureIds, $list->FeatureId);
			}
			$featureUrls = self::getFeatureUrlByFeatureIds(array_unique($featureIds));
		}
		
		foreach($resultList as $list){
			
			$temp = array();
			
			$temp['VideoId'] = $list->Id;
			$temp['VideoName'] = $list->Title;
			$temp['VolNum'] = $list->VolNum;
			$temp['PicUrl_390'] = (!empty($list->ProPicUrl))?self::getImageLink($list->ProPicUrl,390,256):'';
			$temp['PicUrl_340'] = (!empty($list->PicUrl->Filename))?self::getImageLink($list->PicUrl->Filename,340,256):'';
			$temp['PublishDate'] = $list->PublishDate->format('Y-m-d H:i:s');
			$temp['VideoUrl'] = \haibao\classlibrary\Config::getConfig(\haibao\classlibrary\Config::CLASSLIBRARY_CONFIG_HOST_VIDEO).'/play/'.$list->Id.'.htm';
			$temp['VideoDown'] = (!empty($list->videoFile) && $list->videoFile->Status== \haibao\cms\model\data\VideoFile::STATUS_OVER) ? 1 : 0;
			
			if($isJoinCategory){
				$temp['CategoryId'] = $list->CategoryId;
				$temp['CategoryName'] = $list->Category->CategoryName;
				$temp['CategoryUrl'] = \haibao\classlibrary\Config::getConfig(\haibao\classlibrary\Config::CLASSLIBRARY_CONFIG_HOST_VIDEO).'/videoflow/'.$list->CategoryId.'/';
			}
			if($isFeature){
				$temp['FeatureId'] = $list->FeatureId;
				$temp['FeatureUrl'] = (isset($featureUrls[$list->FeatureId]))?$featureUrls[$list->FeatureId]:'';
			}
			array_push($videoList,$temp);
		}
		
	
		if($isPage){
			return array($videoList,$videoFilter->getPager());
		}
		return $videoList;
		
	}
	
	/**
	 * 热门视频
	 */
	public static function getHotPlayVideoList($dateRange = self::ONE_MONTH,$limit = 4,$isJoinCategory=true,$isFeature=true){
		$videoFilter = new VideoFilter();
		$videoCategoryFilter = new VideoCategoryFilter();
		$videoPropertyFilter = new VideoPropertyFilter();
		$imageLibraryFilter = new ImageLibraryFilter();
		$videoFileFilter = new VideoFileFilter();
		$videoFilter->select(array(
				VideoFilter::CONDITION_FIELD_NAME_ID,
				VideoFilter::CONDITION_FIELD_NAME_CATEGORYID,
				VideoFilter::CONDITION_FIELD_NAME_PROPICURL,
				VideoFilter::CONDITION_FIELD_NAME_PUBLISHDATE,
				VideoFilter::CONDITION_FIELD_NAME_VOLNUM,
				VideoFilter::CONDITION_FIELD_NAME_TITLE,
				VideoFilter::CONDITION_FIELD_NAME_FEATUREID
		));
		$videoCategoryFilter->select(array(
				VideoCategoryFilter::CONDITION_FIELD_NAME_CATEGORYNAME
		));
		$imageLibraryFilter->select(array(
				ImageLibraryFilter::CONDITION_FIELD_NAME_FILENAME
		));
		$videoFileFilter->select(array(
				$videoFileFilter::CONDITION_FIELD_NAME_ID,
				$videoFileFilter::CONDITION_FIELD_NAME_STATUS
		));
		$videoFilter->limit($limit);
		if($dateRange == self::ONE_MONTH){
			$videoFilter->where(VideoFilter::CONDITION_FIELD_NAME_PUBLISHDATE,Condition::CONDITION_BETWEEN,array(
					date('Y-m-d',strtotime('-1 months')),date('Y-m-d')
			));
		}

		$videoFilter->order(VideoPropertyFilter::CONDITION_FIELD_NAME_PLAYNUM,false,$videoPropertyFilter);

		$videoFilter->where(VideoFilter::CONDITION_FIELD_NAME_STATUS,Condition::CONDITION_EQUAL,\haibao\cms\model\data\Video::STATUS_ENABLE);
		$videoFilter->where(VideoFilter::CONDITION_FIELD_NAME_PUBLISHED,Condition::CONDITION_EQUAL,\haibao\cms\model\data\Video::PUBLISHED_OK);
		if($isJoinCategory){
			$videoFilter->innerJoin($videoCategoryFilter,null,VideoFilter::CONDITION_FIELD_NAME_CATEGORYID,VideoCategoryFilter::CONDITION_FIELD_NAME_ID,VideoFilter::CONDITION_FIELD_NAME_CATEGORY,false);
		}
		$videoFilter->leftJoin($videoPropertyFilter,null,VideoFilter::CONDITION_FIELD_NAME_ID,VideoPropertyFilter::CONDITION_FIELD_NAME_VIDEOID,VideoFilter::CONDITION_FIELD_NAME_PROPERTY,false);
		$videoFilter->leftJoin($imageLibraryFilter,null,VideoFilter::CONDITION_FIELD_NAME_PICID,ImageLibraryFilter::CONDITION_FIELD_NAME_ID,VideoFilter::CONDITION_FIELD_NAME_PIC_URL,false);
		$data = new \haibao\cms\data\Video();
		$resultList = $data->getAll($videoFilter);
		$videoList = array();
		
		if($isFeature){

			$featureUrls = $featureIds = array();
			foreach ($resultList as $list){
				if($list->FeatureId) array_push($featureIds, $list->FeatureId);
			}
			$featureUrls = self::getFeatureUrlByFeatureIds(array_unique($featureIds));
		}
		
		foreach($resultList as $list){
			$temp = array();
			$temp['VideoId'] = $list->Id;
			$temp['VideoName'] = $list->Title;
			$temp['VolNum'] = $list->VolNum;
			$temp['FeatureId'] = $list->FeatureId;
			$temp['PicUrl_390'] = (!empty($list->ProPicUrl))?self::getImageLink($list->ProPicUrl,390,256):'';
			$temp['PicUrl_340'] = (!empty($list->PicUrl->Filename))?self::getImageLink($list->PicUrl->Filename,340,256):'';
			$temp['PublishDate'] = $list->PublishDate->format('Y-m-d H:i:s');
			$temp['VideoUrl'] = \haibao\classlibrary\Config::getConfig(\haibao\classlibrary\Config::CLASSLIBRARY_CONFIG_HOST_VIDEO).'/play/'.$list->Id.'.htm';
			$temp['VideoDown'] = (!empty($list->videoFile) && $list->videoFile->Status== \haibao\cms\model\data\VideoFile::STATUS_OVER) ? 1 : 0;
				
			if($isFeature){
				$temp['FeatureUrl'] = (isset($featureUrls[$list->FeatureId]))?$featureUrls[$list->FeatureId]:'';
			}
			if($isJoinCategory){
				$temp['CategoryId'] = $list->CategoryId;
				$temp['CategoryName'] = $list->Category->CategoryName;
				$temp['CategoryUrl'] = \haibao\classlibrary\Config::getConfig(\haibao\classlibrary\Config::CLASSLIBRARY_CONFIG_HOST_VIDEO).'/videoflow/'.$list->CategoryId.'/';
			}
				
			
			array_push($videoList,$temp);
		}
		
		return $videoList;
	}
	
	/**
	 * 取得视频对应的专题的url
	 */
	public static function getFeatureUrlByFeatureIds($featureIds){
		$featureUrl = array();
		if(empty($featureIds)) return $featureUrl;
		$featurePublishFilter = new FeaturePublishFilter();
		$featurePublishFilter->select(array(
				$featurePublishFilter::CONDITION_FIELD_NAME_ID,
				$featurePublishFilter::CONDITION_FIELD_NAME_URL,
				$featurePublishFilter::CONDITION_FIELD_NAME_FEATURE_DEFINE_ID
		));
		$featurePublishFilter->where($featurePublishFilter::CONDITION_FIELD_NAME_IS_H5, Condition::CONDITION_EQUAL, \haibao\cms\model\data\FeaturePublish::IS_NOT_H5);
		$featurePublishFilter->where($featurePublishFilter::CONDITION_FIELD_NAME_ID, Condition::CONDITION_IN, $featureIds);
		$featurePublishFilter->where($featurePublishFilter::CONDITION_FIELD_NAME_STATUS, Condition::CONDITION_EQUAL, \haibao\cms\model\data\FeaturePublish::STATUS_PUBLISH);
		$data = new \haibao\cms\data\FeaturePublish();
		$resultList = $data->getAll($featurePublishFilter);
		foreach($resultList as $list){
			$featureUrl[$list->Id] = $list->Url;
		}
		return $featureUrl;
	}
	
	/**
	 * 根据视频id取得视频是否可以被下载
	 */
	public static function getDownloadByVideoId($videoIds){
		$videoDown = array();
		$videoFileFilter = new VideoFileFilter();
		$videoFileFilter->select(array(
				$videoFileFilter::CONDITION_FIELD_NAME_ID,
				$videoFileFilter::CONDITION_FIELD_NAME_VIDEOID,
				$videoFileFilter::CONDITION_FIELD_NAME_STATUS
		));
		$videoFileFilter->where($videoFileFilter::CONDITION_FIELD_NAME_STATUS, Condition::CONDITION_EQUAL, \haibao\cms\model\data\VideoFile::STATUS_OVER);
		$videoFileFilter->where($videoFileFilter::CONDITION_FIELD_NAME_VIDEOID, Condition::CONDITION_IN, $videoIds);
		$data = new \haibao\cms\data\Video();
		$resultList = $data->getAll($videoFileFilter);
		foreach($resultList as $list){
			$videoDown[$list->VideoId] = \haibao\cms\model\data\VideoFile::STATUS_OVER;
		}
		return $videoDown;
	}
	
	
	/**
	 * 获取视频分类相关信息
	 */
	public static function getVideoCategoryByCategoryId($categoryId){
	
		$videoCategoryFilter = new VideoCategoryFilter();
		if(is_array($categoryId)){
			$videoCategoryFilter->where(VideoCategoryFilter::CONDITION_FIELD_NAME_ID,Condition::CONDITION_IN,$categoryId);
		}
		$data = new \haibao\cms\data\Video();
		$resultList = $data->getAll($videoCategoryFilter);
		$videoCategoryList = array();
		foreach($resultList as $result){
			$videoCategoryList[$result->Id] = $result->toArray();
		}
		return $videoCategoryList;
	}
	
	public static function getVideoById($videoId,$isJoinCategory = true,$isJoinTag=true ,$isJoinProperty=true){

		$videoFilter = new VideoFilter();
		$videoCategoryFilter = new VideoCategoryFilter();
		$videoTagFilter = new VideoRelTagFilter();
		$videoPropertyFilter = new VideoPropertyFilter();
		$videoFileFilter = new VideoFileFilter();
		$videoFilter->select(array(
				VideoFilter::CONDITION_FIELD_NAME_ID,
				VideoFilter::CONDITION_FIELD_NAME_CATEGORYID,
				VideoFilter::CONDITION_FIELD_NAME_PROPICURL,
				VideoFilter::CONDITION_FIELD_NAME_PUBLISHDATE,
				VideoFilter::CONDITION_FIELD_NAME_VOLNUM,
				VideoFilter::CONDITION_FIELD_NAME_TITLE,
				VideoFilter::CONDITION_FIELD_NAME_FEATUREID,
				VideoFilter::CONDITION_FIELD_NAME_FOCUSPIC,
				VideoFilter::CONDITION_FIELD_NAME_SURFACE_PICID,
				VideoFilter::CONDITION_FIELD_NAME_VIDEOURL,
				VideoFilter::CONDITION_FIELD_NAME_URLH5,
				VideoFilter::CONDITION_FIELD_NAME_PUBLISHDATE,
				VideoFilter::CONDOTION_FIELD_NAME_DESCRIPTION,
		));
		$videoCategoryFilter->select(array(
				VideoCategoryFilter::CONDITION_FIELD_NAME_CATEGORYNAME
		));
		$videoTagFilter->select(array(
				VideoRelTagFilter::CONDITION_FIELD_NAME_TAGID
		));
		$videoPropertyFilter->select(array(
				VideoPropertyFilter::CONDITION_FIELD_NAME_LOVENUM,
				VideoPropertyFilter::CONDITION_FIELD_NAME_PLAYNUM,
				VideoPropertyFilter::CONDITION_FIELD_NAME_UPNUM,
		));
		$videoFileFilter->select(array(
				$videoFileFilter::CONDITION_FIELD_NAME_ID,
				$videoFileFilter::CONDITION_FIELD_NAME_STATUS
		));
		
		$videoFilter->where(VideoFilter::CONDITION_FIELD_NAME_STATUS,Condition::CONDITION_EQUAL,\haibao\cms\model\data\Video::STATUS_ENABLE);
		$videoFilter->where(VideoFilter::CONDITION_FIELD_NAME_PUBLISHED,Condition::CONDITION_EQUAL,\haibao\cms\model\data\Video::PUBLISHED_OK);
		$videoFilter->where(VideoFilter::CONDITION_FIELD_NAME_ID,Condition::CONDITION_EQUAL,$videoId);
		$videoFilter->leftJoin($videoFileFilter,null,VideoFilter::CONDITION_FIELD_NAME_ID,$videoFileFilter::CONDITION_FIELD_NAME_VIDEOID,VideoFilter::CONDITION_FIELD_NAME_VIDEOFILE,false);
		
		
		if($isJoinCategory){
			$videoFilter->innerJoin($videoCategoryFilter,null,VideoFilter::CONDITION_FIELD_NAME_CATEGORYID,VideoCategoryFilter::CONDITION_FIELD_NAME_ID,VideoFilter::CONDITION_FIELD_NAME_CATEGORY,false);
		}
		
		if($isJoinTag){
			$videoFilter->innerJoin($videoTagFilter,null,VideoFilter::CONDITION_FIELD_NAME_ID,VideoRelTagFilter::CONDITION_FIELD_NAME_VIDEOID,VideoFilter::CONDITION_FIELD_NAME_TAGS,false);
			$videoTagFilter->where(VideoRelTagFilter::CONDITION_FIELD_NAME_ISPARIMARY,Condition::CONDITION_EQUAL,\haibao\cms\model\data\VideoRelTag::IS_PRIMARY);
		}

		if($isJoinProperty){
			$videoFilter->innerJoin($videoPropertyFilter,null,VideoFilter::CONDITION_FIELD_NAME_ID,VideoPropertyFilter::CONDITION_FIELD_NAME_VIDEOID,VideoFilter::CONDITION_FIELD_NAME_PROPERTY,false);
		}
		
		
		$data = new \haibao\cms\data\Video();
		$video = $data->getOne($videoFilter);
		if($video && $video->SurfacePicId){
			$imageInfo = \haibao\cms\business\ImageLibrary::getImageUrlById($video->SurfacePicId);
			$video->SurfacePicId = (isset($imageInfo[$video->SurfacePicId]))?self::getImageLink($imageInfo[$video->SurfacePicId],750,435):0;
		} 
		return $video;
	}
	
	
	/**
	 * 根据视频分类获取视频数据
	 * @param  $categoryId
	 */
	public static function getNewVideoList($page,$isPage=true,$limit=12,$isJoinCategory=true,$isFeature=true,$notInVideoId=array(),$isH5Exist = 0){
	
		$videoFilter = new VideoFilter();
		$videoCategoryFilter = new VideoCategoryFilter();
		$imageLibraryFilter = new ImageLibraryFilter();
		$videoFilter->select(array(
				VideoFilter::CONDITION_FIELD_NAME_ID,
				VideoFilter::CONDITION_FIELD_NAME_CATEGORYID,
				VideoFilter::CONDITION_FIELD_NAME_PROPICURL,
				VideoFilter::CONDITION_FIELD_NAME_PUBLISHDATE,
				VideoFilter::CONDITION_FIELD_NAME_VOLNUM,
				VideoFilter::CONDITION_FIELD_NAME_TITLE,
				VideoFilter::CONDITION_FIELD_NAME_FEATUREID
		));
		$videoCategoryFilter->select(array(
				VideoCategoryFilter::CONDITION_FIELD_NAME_CATEGORYNAME
		));
		$imageLibraryFilter->select(array(
				ImageLibraryFilter::CONDITION_FIELD_NAME_FILENAME
		));
		if($isPage){
			$videoFilter->setPager(new Pager($limit,$page));
		}else{
			if($limit){
				$videoFilter->limit($limit);
			}
		}
		if($notInVideoId){
			$videoFilter->where(VideoFilter::CONDITION_FIELD_NAME_ID,Condition::CONDITION_NOTIN,$notInVideoId);
		}
		
		if($isH5Exist){
			$videoFilter->where(VideoFilter::CONDITION_FIELD_NAME_URLH5, Condition::CONDITION_NOTEQUAL,'');
		}
		
		$videoFilter->where(VideoFilter::CONDITION_FIELD_NAME_STATUS,Condition::CONDITION_EQUAL,\haibao\cms\model\data\Video::STATUS_ENABLE);
		$videoFilter->where(VideoFilter::CONDITION_FIELD_NAME_PUBLISHED,Condition::CONDITION_EQUAL,\haibao\cms\model\data\Video::PUBLISHED_OK);
		$videoFilter->order(VideoFilter::CONDITION_FIELD_NAME_PUBLISHDATE,false);
		if($isJoinCategory){
			$videoFilter->innerJoin($videoCategoryFilter,null,VideoFilter::CONDITION_FIELD_NAME_CATEGORYID,VideoCategoryFilter::CONDITION_FIELD_NAME_ID,VideoFilter::CONDITION_FIELD_NAME_CATEGORY,false);
		}
		$videoFilter->leftJoin($imageLibraryFilter,null,VideoFilter::CONDITION_FIELD_NAME_PICID,ImageLibraryFilter::CONDITION_FIELD_NAME_ID,VideoFilter::CONDITION_FIELD_NAME_PIC_URL,false);
		$data = new \haibao\cms\data\Video();
		$resultList = $data->getAll($videoFilter);
		$videoList = array();
	
	
		if($isFeature){
			$featureUrls = $featureIds = array();
			foreach ($resultList as $list){
				if($list->FeatureId) array_push($featureIds, $list->FeatureId);
			}
			$featureUrls = self::getFeatureUrlByFeatureIds(array_unique($featureIds));
		}
	
		foreach($resultList as $list){
				
			$temp = array();
				
			$temp['VideoId'] = $list->Id;
			$temp['VideoName'] = $list->Title;
			$temp['VolNum'] = $list->VolNum;
			$temp['PicUrl_390'] = (!empty($list->ProPicUrl))?self::getImageLink($list->ProPicUrl,390,256):'';
			$temp['PicUrl_340'] = (!empty($list->PicUrl->Filename))?self::getImageLink($list->PicUrl->Filename,340,256):'';
			$temp['PublishDate'] = $list->PublishDate->format('Y-m-d H:i:s');
			$temp['VideoUrl'] = \haibao\classlibrary\Config::getConfig(\haibao\classlibrary\Config::CLASSLIBRARY_CONFIG_HOST_VIDEO).'/play/'.$list->Id.'.htm';
			$temp['VideoDown'] = (!empty($list->videoFile) && $list->videoFile->Status== \haibao\cms\model\data\VideoFile::STATUS_OVER) ? 1 : 0;
			
			if($isJoinCategory){
				$temp['CategoryId'] = $list->CategoryId;
				$temp['CategoryName'] = $list->Category->CategoryName;
				$temp['CategoryUrl'] = \haibao\classlibrary\Config::getConfig(\haibao\classlibrary\Config::CLASSLIBRARY_CONFIG_HOST_VIDEO).'/videoflow/'.$list->CategoryId.'/';
			}
			if($isFeature){
				$temp['FeatureId'] = $list->FeatureId;
				$temp['FeatureUrl'] = (isset($featureUrls[$list->FeatureId]))?$featureUrls[$list->FeatureId]:'';
			}
			array_push($videoList,$temp);
		}
	
	
		if($isPage){
			return array($videoList,$videoFilter->getPager());
		}
		return $videoList;
	
	}
	
	public static function getVideoCategory(){
		$arrCate = array();
		$categoryTree = \haibao\cms\business\VideoCategory::getCategoryTree();
		foreach ($categoryTree as $list){
			if(isset($list['children'])){
				$children = $list['children'];
				$arr = array();
				foreach ($children as $val){
					$arr[$val['CategoryName']] = $val['Id'];
				}
				$arrCate[$list['Id']] = $arr;
			}else{
				$arrCate[$list['Id']] = $list['CategoryName'];
			}
		}
		return $arrCate;
	}
} 